function SetUpInstallmentsList() { var frequencyId = $('#ddlDonationFrequency :selected').val(); $('#ddlInstallments').html(''); var _maxNumber = frequencyId == 1 ? _maxInstallments : _maxRecurrings; if (_maxNumber > 0) { $('').val(-1).text(frequencyId == 1 ? selectInstallmentsText : selectInstallmentsMonthlyText).appendTo($('#ddlInstallments')); $('#ddlInstallments').change(); for (var i = 1; i <= _maxNumber; i++) { $('').val(i).text(i).appendTo($('#ddlInstallments')); } $("#ddlInstallments > option").each(function () { if ($(this).val() == '1') { $(this).text($(this).val() + ' ' + (frequencyId == 1 ? _installmentsCountOne : _installmentsCountOneMonthly)); } else if ($(this).val() > '1') { $(this).text($(this).val() + ' ' + (frequencyId == 1 ? _installmentsCountPlural : _installmentsCountPluralMonthly)); } }); } if (frequencyId == 2) { $('#ancToggleTashlumim').show(); $('#divInstallments').hide(); } else if (frequencyId == 1) { if (_maxNumber > 0) { $('#divInstallments').show(); } else { $('#divInstallments').hide(); } $('#ancToggleTashlumim').hide(); } else { $('#ancToggleTashlumim').hide(); $('#divInstallments').hide(); } if (typeof AfterSetUpInstallmentsList != 'undefined' && $.isFunction(AfterSetUpInstallmentsList)) { AfterSetUpInstallmentsList(); } } function ToggleTashlumim() { if ($('#divInstallments').is(':visible')) { $('#hdnTashlumim').val(''); $('#divInstallments').hide(); $('#divInstallments').val('1'); } else { $('#divInstallments').show(); } } $(document).ready(function () { if (_maxRecurrings > 0) { /*var txt = "I'd like to donate for a set number of months"; if (isHeb()) { txt = 'אני רוצה לתרום למספר קבוע של חודשים'; } */ var txt = _limitNoOfMonth; $('#extrasums').append('' + '' + '' + '' + txt + '' + '' + '' + ''); var frequencyId = $('#ddlDonationFrequency :selected').val(); if (frequencyId == 2) { $('#ancToggleTashlumim').show(); } $('#divInstallments label').html(''); $('#ddlDonationFrequency').change(function () { var frequencyId = $('#ddlDonationFrequency :selected').val(); $('#hdnTashlumim').val(''); SetUpInstallmentsList(); if (frequencyId >= 2) { $('#hdnRealTash').val(''); } else { $('#hdnRealTash').val('1'); } }); $('#ddlInstallments').change(function () { $('#hdnTashlumim').val(''); if ($('#ddlInstallments').val() != "1" || $('#ddlInstallments').val() != "") { var frequencyId = $('#ddlDonationFrequency :selected').val(); $('#hdnTashlumim').val($('#ddlInstallments').val()); if (frequencyId == 1) { $('#hdnRecurringLimit').val(); } else if (frequencyId == 2) { $('#hdnRecurringLimit').val("1"); } } }); } });